home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / PALETTE_.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.0 KB  |  108 lines

  1. /*
  2.  * $Id: palette_button.java,v 1.10 1996/10/03 19:45:17 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.lib;
  7.  
  8. import sub_arctic.input.event;
  9. import sub_arctic.input.callback_object;
  10. import sub_arctic.input.inout_draggable;
  11. import sub_arctic.input.pressable;
  12.  
  13. import sub_arctic.output.color_pair;
  14. import sub_arctic.output.loaded_image;
  15. import sub_arctic.output.drawable;
  16.  
  17. import java.awt.Point;
  18. import java.awt.Dimension;
  19. import java.awt.Image;
  20. import java.awt.Font;
  21. import java.awt.FontMetrics;
  22. import java.awt.Color;
  23.  
  24. /** 
  25.  * A button which acts on the downward mouse button press.  This is suitable
  26.  * for a situation such as a palette where you need to create an object and
  27.  * drag it away from the point of first interaction in one motion.
  28.  *
  29.  * @author Scott Hudson
  30.  */
  31. public class palette_button extends multi_button 
  32.   implements inout_draggable, pressable {
  33.  
  34.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  35.  
  36.   /** 
  37.    * Full constructor.  The two image sets provided give normal appearance
  38.    * for each state of the button, and a transition appearance out of each
  39.    * state of the button.  The transition set may be coded as null in which
  40.    * case the next state image is used when a transition is needed.  Otherwise
  41.    * the two image sets must be the same size.  For this subclass the transition
  42.    * appearance will never show up since we just straight to the new state on
  43.    * mouse down.
  44.    *
  45.    * @param int              x           x position of the interactor.
  46.    * @param int              y           y position of the interactor.
  47.    * @param loaded_image[]   st_looks    images for normal look of button in 
  48.    *                                     various states.
  49.    * @param loaded_image[]   trans_looks images for looks during transitions 
  50.    *                                     between states (typically null since 
  51.    *                                     transition appearance does not show up
  52.    *                                     in this subclass).
  53.    * @param callback_object  call_obj    the callback object that gets notified
  54.    *                                     when this button changes state.
  55.    */
  56.   public palette_button(
  57.     int              x,
  58.     int              y,
  59.     loaded_image[]   st_looks, 
  60.     loaded_image[]   trans_looks, 
  61.     callback_object  call_obj)
  62.     {
  63.       super(x,y,st_looks,trans_looks,call_obj);
  64.     }
  65.  
  66.    //had:
  67.    //* @exception bad_value                if the image arrays are not the same 
  68.    //*                                     size.
  69.    //* @exception general
  70.  
  71.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  72.  
  73.   /** 
  74.    * Handle mouse presses in our bounds.  For a palette button we act on the
  75.    * press itself (so the button is still down and we can immediately take
  76.    * up a drag action).  To do that we fake the end of the inout_drag
  77.    * that a multi_button normally does and let the superclass do the 
  78.    * normal end of input actions.
  79.    *
  80.    * @param event  evt       the mouse down event. 
  81.    * @param Object user_info information associated with this object at 
  82.    *                         pick time.
  83.    */
  84.   public boolean press(event evt, Object user_info)
  85.     {
  86.       /* fake end of inout_drag with cursor inside object */
  87.       return inout_drag_end(evt, true, user_info);
  88.     }
  89.  
  90.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  91. }
  92. /*=========================== COPYRIGHT NOTICE ===========================
  93.  
  94. This file is part of the subArctic user interface toolkit.
  95.  
  96. Copyright (c) 1996 Scott Hudson and Ian Smith
  97. All rights reserved.
  98.  
  99. The subArctic system is freely available for most uses under the terms
  100. and conditions described in 
  101.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  102. and appearing in full in the lib/interactor.java source file.
  103.  
  104. The current release and additional information about this software can be 
  105. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  106.  
  107. ========================================================================*/
  108.